/**
 *
 */
package com.fortune.rainshinesystem.controller;

import com.fortune.rainshinecommon.base.MsgModel;
import com.fortune.rainshinecommon.base.ParmsModel;
import com.fortune.rainshinecommon.model.CustomerModel;
import com.fortune.rainshinesystem.service.CustomerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 张鑫
 * @ClassName: CustomerController
 * @Description: TODO(顾客维护)
 * @phone 17561783855
 * @date 2019年5月15日
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerService service;

    //添加
    @RequiresPermissions("customer:add")
    @PostMapping("/add")
    public MsgModel add(@RequestBody CustomerModel model) {
        return service.add(model);
    }

    //更新
    @RequiresPermissions("customer:update")
    @PostMapping("/update")
    public MsgModel update(@RequestBody CustomerModel model) {
        return service.update(model);
    }

    //获取列表
    @RequiresPermissions("customer:view")
    @PostMapping("/list")
    public MsgModel list(@RequestBody ParmsModel parms) {
        return service.list(parms);
    }

    //删除
    @RequiresPermissions("customer:delete")
    @PostMapping("/delete")
    public MsgModel del(@RequestBody CustomerModel model) {
        return service.del(model);
    }
    
  //删除
    @RequiresPermissions("customer:back")
    @PostMapping("/back")
    public MsgModel back(@RequestBody CustomerModel model) {
        return service.back(model);
    }

    //根据id获取顾客信息
    @PostMapping("/getCustomer")
    public CustomerModel getCustomer(@RequestBody Integer customerId) {
        return service.getCustomer(customerId);
    }
    
    //获取激活状态的客户
    @RequiresPermissions("customer:view")
    @PostMapping("/listActive")
    public MsgModel listActive(@RequestBody ParmsModel parms) {
        return service.listActive(parms);
    }
}
